package com.vdong.trade.trading.facade.enums;


/**
 * @author <a href="mailto:clf@vdongzc.com">clf</a>
 * @Description: 微信支付相关枚举
 * @Date Create on 2018-12-13 15:10:22
 * @since version1.0
 */
public class WechatPayEnums {

    /**
     * 订单业务类型
     */
    public enum OrderTypeEnum {

        USER_PAY(1, "个人转商户"),
        MERCHANT_PAY(2, "商户转个人"),
        USER_REFUND(3, "个人退款");

        private final Integer type;

        private final String desc;

        OrderTypeEnum(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }

        public Integer getType() {
            return type;
        }

        public String getDesc() {
            return desc;
        }
    }

    /**
     * 支付类型
     */
    public enum TradeTypeEnum {
        JSAPI1(1, "JSAPI", "小程序支付"),
        JSAPI2(2, "JSAPI", "公众号支付"),
        NATIVE(3, "NATIVE", "扫码支付"),
        APP(4, "APP", "app支付");

        private final Integer code;

        private final String type;

        private final String desc;

        TradeTypeEnum(Integer code, String type, String desc) {
            this.code = code;
            this.type = type;
            this.desc = desc;
        }

        public Integer getCode() {
            return code;
        }

        public String getType() {
            return type;
        }

        public String getDesc() {
            return desc;
        }
    }

    public enum PayStatusEnum {
        PAY_INIT((short) 0, "预订单初始状态/未同步回调"),
        PAY_AWAIT((short) 1, "预订单初始状态/已同步回调,待支付"),
        PAY_SUCCESS((short) 2, "支付成功"),
        PAY_FAILED((short) 3, "支付失败"),
        PAY_BACK((short) 4, "已退款"),
        PAY_SYSTEM_ERROR((short) 5, "第三方支付返回系统异常");

        private final Short status;

        private final String desc;

        PayStatusEnum(Short status, String desc) {
            this.status = status;
            this.desc = desc;
        }

        public Short getStatus() {
            return status;
        }

        public String getDesc() {
            return desc;
        }

        public static PayStatusEnum getEnum(int value) {
            for (PayStatusEnum statusEnum : PayStatusEnum.values()) {
                if (statusEnum.getStatus() == value) {
                    return statusEnum;
                }
            }
            return null;
        }
    }

}
